import Mock from "mockjs";
const articles = [{
        title: "如何提高代码质量？",
        author: "小明",
        time: "2022-01-01",
        summary: "在日常工作中，我们经常会遇到需要修改他人代码的情况。",
        thumb: 1,
        view: 2,
        commentNum: 1,
        url: "https://example.com/article/1",
    },
    {
        title: "JavaScript 中 this 的使用技巧",
        author: "小红",
        time: "2022-01-02",
        summary: "在 JavaScript 中，this 是一个非常重要的关键字，它用来指代当前对象。",
        thumb: 3,
        view: 10,
        commentNum: 5,
        url: "https://example.com/article/2",
    },
    {
        title: "Vue.js 组件通信方式详解",
        author: "小刚",
        time: "2022-01-03",
        summary: "在 Vue.js 中，组件通信是一个非常重要的概念，我们需要灵活掌握不同的通信方式。",
        thumb: 2,
        view: 8,
        commentNum: 3,
        url: "https://example.com/article/3",
    },
    {
        title: "如何写出高质量的 React 组件？",
        author: "小李",
        time: "2022-01-04",
        summary: "React 是目前最受欢迎的前端框架之一，如何写出高质量的 React 组件是每个开发者都需要掌握的技能。",
        thumb: 5,
        view: 15,
        commentNum: 7,
        url: "https://example.com/article/4",
    },
    {
        title: "Python 中的函数式编程",
        author: "小猪",
        time: "2022-01-05",
        summary: "Python 支持函数式编程，这为我们编写简洁、高效的代码提供了更多的选择。",
        thumb: 4,
        view: 12,
        commentNum: 4,
        url: "https://example.com/article/5",
    },
    {
        title: "如何提高 Git 使用技巧？",
        author: "小鸟",
        time: "2022-01-06",
        summary: "Git 是目前最流行的版本控制工具之一，如何熟练地使用 Git 是每个开发者都需要掌握的技能。",
        thumb: 2,
        view: 9,
        commentNum: 2,
        url: "https://example.com/article/6",
    },
    {
        title: "Java 中的多线程编程",
        author: "小鱼",
        time: "2022-01-07",
        summary: "在 Java 中，多线程编程是非常常见的，我们需要了解多线程的概念、使用方法和常见的问题。",
        thumb: 6,
        view: 20,
        commentNum: 10,
        url: "https://example.com/article",
    },
    {
        title: "如何优化前端性能？",
        author: "张三",
        time: "2022-01-02",
        summary: "前端性能优化是前端开发工作中非常重要的一部分。",
        thumb: 3,
        view: 5,
        commentNum: 2,
        url: "https://example.com/article/2",
    },
    {
        title: "学习Vue.js的经验分享",
        author: "李四",
        time: "2022-01-03",
        summary: "Vue.js是一种流行的JavaScript框架，它在前端开发中广泛应用。",
        thumb: 2,
        view: 3,
        commentNum: 1,
        url: "https://example.com/article/3",
    },
    {
        title: "如何学习Python？",
        author: "王五",
        time: "2022-01-04",
        summary: "Python是一种非常流行的编程语言，适合于多种场景。",
        thumb: 5,
        view: 10,
        commentNum: 4,
        url: "https://example.com/article/4",
    },
    {
        title: "如何使用Git进行团队协作开发？",
        author: "赵六",
        time: "2022-01-05",
        summary: "Git是一种非常流行的版本控制系统，适合于团队协作开发。",
        thumb: 1,
        view: 2,
        commentNum: 0,
        url: "https://example.com/article/5",
    },
    {
        title: "如何编写高质量的JavaScript代码？",
        author: "钱七",
        time: "2022-01-06",
        summary: "JavaScript是一种非常灵活的编程语言，但也容易出现问题。",
        thumb: 3,
        view: 4,
        commentNum: 1,
        url: "https://example.com/article/6",
    },
];
export default () => {
    return Mock.mock("/api/articles", "get", (options) => {
        const { limit = 10, page = 1 } = JSON.parse(options.body);
        const startIndex = (page - 1) * limit;
        const endIndex = startIndex + limit;
        const data = articles.slice(startIndex, endIndex);
        return {
            code: 200,
            message: "success",
            data,
        };
    });
};